package cn.sc.summer.protocol.prometheus;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 类名：PrometheusCustomMonitor指标参数
 *
 * @author a-xin
 * @date 2023/9/1 10:11
 */
@Data
@Component
public class SysPrometheusMonitor {

    /**
     * 接口访问次数
     */
    private Counter orderCount;

    /**
     * sql执行异常数据统计
     */
    private Counter errorSqlCount;

    private final MeterRegistry registry;

    @Autowired
    public SysPrometheusMonitor(MeterRegistry registry) {
        this.registry = registry;
    }

    @PostConstruct
    private void init() {
        orderCount = registry.counter("sys_request_count", "sys", "request_total");
        errorSqlCount = registry.counter("error_sql_count", "project", "error total");
    }

}

